package com.xcx.robot.mirai.factory.facade;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.xcx.robot.mirai.entity.JX3API;
import com.xcx.robot.mirai.factory.BaseFacade;
import com.xcx.robot.mirai.jxapi.Result;
import com.xcx.robot.mirai.key.KeyWord;
import net.mamoe.mirai.contact.Contact;
import org.springframework.stereotype.Service;

/**
 * @Author: 邢晨旭
 * @Date: 2021/6/22 09:33
 * @Description:
 */
@Service
public class FlattererFacade implements BaseFacade {
    public KeyWord keyWord = KeyWord.FLATTERER;


    @Override
    public void execute(Contact sender, Contact receiver, String content) {
        String s = HttpUtil.get(JX3API.FLATTERER);
        Result result = JSONObject.parseObject(s, Result.class);
        if (result.getCode() == 200) {
            receiver.sendMessage(result.getData().getText());
        }
    }

    @Override
    public KeyWord keyWord() {
        return keyWord;
    }
}
